include(FindPackageHandleStandardArgs)

# todo 修改库名
set(PKGNAME muduo)

# 设置包名称
set(pkg_found ${PKGNAME}_FOUND)
set(${pkg_found} TRUE) # 自动设置为TRUE，因为 muduo 已经存在
message("${pkg_found}  ${${pkg_found}}")


set(PKG_INSTALL_PREFIX ${PKGNAME}_INSTALL_PREFIX)

# 假设我们在 <install-prefix>/share/cmake/pkg/PkgConfig.cmake 中
get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
# message("CMAKE_CURRENT_LIST_DIR " ${CMAKE_CURRENT_LIST_DIR})
get_filename_component(${PKG_INSTALL_PREFIX} "${CMAKE_CURRENT_LIST_DIR}/" ABSOLUTE)

# message(PKG_INSTALL_PREFIX ${${PKG_INSTALL_PREFIX}})
# 设置包含目录和库路径
set(PKG_INCLUDE_DIRS "${${PKG_INSTALL_PREFIX}}/include")
# message("INCLUDE_DIRS " ${PKG_INCLUDE_DIRS})


# 暴力查找lib文件,为何多此一举,因为怕CMAKE_BUILD_TYPE为release_info,和空值
#message(${${PKG_INSTALL_PREFIX}})

file(GLOB PKG_LIBRARY
        ${${PKG_INSTALL_PREFIX}}/lib/*.a
)


add_library(${PKGNAME} SHARED IMPORTED)
#message(PKG_LIBRARY ${PKG_LIBRARY})
set_target_properties(${PKGNAME} PROPERTIES
        IMPORTED_LOCATION "${PKG_LIBRARY}"
)

list(APPEND build_copy_list ${PKG_DLL} ${PKG_OTHER})



